package indi.kane.demandlist.dao;

import indi.kane.demandlist.entity.Developer;
import indi.kane.demandlist.vo.ResultVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

/**
 * @ClassName: DeveloperMapper
 * @Author: kane
 * @Date: 2020-06-09 11:59 上午
 * @Description:
 */
public interface DeveloperMapper {
    @Select("SELECT * FROM developer WHERE member=#{member};")
    List<Developer> selectByMember(@Param("member") Integer member);

    @Select("SELECT * FROM developer WHERE demand=#{demand};")
    List<Developer> selectByDemand(@Param("demand") Integer demand);

    @Select("DELETE FROM developer WHERE demand=#{demand};")
    int deleteByDemand(@Param("demand") Integer demand);

    @Select("INSERT INTO developer (demand,member) VALUES(#{demand},#{member});")
    @SelectKey(statement="call identity()", keyProperty="id", before=false, resultType=int.class)
    int insert(@Param("demand") Integer demand, @Param("member") Integer member);

    @Select("UPDATE FROM developer SET demand=#{demand}, member=#{member} WHERE id=#{id};")
    int update(@Param("id") Integer id,@Param("demand") Integer demand, @Param("member") Integer member);
}